package com.example.administrator.newjiajiesong.test;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


import com.example.administrator.newjiajiesong.JsonUtils;
import com.example.administrator.newjiajiesong.R;

import java.util.ArrayList;
import java.util.List;

import mlxy.utils.L;

/**
 * 项目名：erp
 * 包名：com.realize.erp.view.fragment
 * 文件名：DataFragment
 * 创建者：任剑波
 * 创建时间：2017/10/16   15:43
 * 描述：TODO
 */

public class DataFragmenttfive extends BaseMvpFragment<IInviteMessageView, InviteMessagePresenter>
        implements IInviteMessageView {
    private static final String TAG = "InviteMessageFragment";
    private InviteMessageAdapter mAdapter;
    private RLListPager mRlpInvite;
    getstore inviteMessages;
    private TextView tv_test;

    @Override
    protected InviteMessagePresenter createPresenter() {
        return new InviteMessagePresenter(this);
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_invite_message, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        mRlpInvite = (RLListPager) view.findViewById(R.id.rlp_invite);
        mRlpInvite.setOnRLRefreshAndLoadMoreListener(new MyOnRLRefreshAndLoadMoreListener());
//        mAdapter = new InviteMessageAdapter(mContext, mList);
//        mRlpInvite.setAdapter(mAdapter);
        tv_test = (TextView)view.findViewById(R.id.fanhuishuju);
        mPresenter.getInviteMessageRefresh(inviteMessages);
        String s = JsonUtils.toJson(inviteMessages);
        L.e("fragment"+s);
    }

    @Override
    public void getMessageResult(boolean isSuccess, boolean hasMore, String errorMsg) {
        if (isSuccess) {
            mAdapter.myNotifyDataSetChanged(hasMore);
        } else {
            toast(errorMsg);
        }
        mRlpInvite.setRefresh(false);
    }

    @Override
    public void showTextview(getstore inviteMessages) {
        tv_test.setText(inviteMessages.getData().get(0).getStore_name());
    }

    /**
     * 刷新/加载更多回调接口
     */
    private class MyOnRLRefreshAndLoadMoreListener implements RLListPager.OnRLRefreshAndLoadMoreListener {
        @Override
        public void onRefresh() {
            //刷新
        }

        @Override
        public void onLoadMore() {
            //加载更多
        }
    }


}